package com.huawei.hms.auth.api.signin.internal;

import android.text.TextUtils;
import com.huawei.hms.common.ApiException;
import com.huawei.hms.common.internal.AnyClient;
import com.huawei.hms.common.internal.ResponseErrorCode;
import com.huawei.hms.common.internal.TaskApiCall;
import com.huawei.hms.support.api.client.Status;
import com.huawei.hms.support.api.hwid.SignOutResult;
import com.huawei.hms.support.log.HMSLog;
import com.huawei.hwid.core.constants.HwAccountConstants;
import o.fjx;
import org.json.JSONException;

public class g extends TaskApiCall<b, Void> {
    public /* synthetic */ void doExecute(AnyClient anyClient, ResponseErrorCode responseErrorCode, String str, fjx o_fjx) {
        a((b) anyClient, responseErrorCode, str, o_fjx);
    }

    public g(String str, String str2) {
        super(str, str2);
    }

    protected void a(b bVar, ResponseErrorCode responseErrorCode, String str, fjx<Void> o_fjx_java_lang_Void) {
        a(responseErrorCode, str);
        if (TextUtils.isEmpty(str)) {
            o_fjx_java_lang_Void.ॱ(new ApiException(new Status(responseErrorCode.getErrorCode(), responseErrorCode.getErrorReason())));
            return;
        }
        try {
            SignOutResult fromJson = new SignOutResult().fromJson(str);
            if (fromJson.isSuccess()) {
                o_fjx_java_lang_Void.ॱ(null);
            } else {
                o_fjx_java_lang_Void.ॱ(new ApiException(fromJson.getStatus()));
            }
        } catch (JSONException e) {
            o_fjx_java_lang_Void.ॱ(new ApiException(new Status(responseErrorCode.getErrorCode(), responseErrorCode.getErrorReason())));
        }
    }

    private void a(ResponseErrorCode responseErrorCode, String str) {
        StringBuilder stringBuilder = new StringBuilder();
        stringBuilder.append("headerErrorCode:" + responseErrorCode.getErrorCode());
        if (str == null) {
            str = HwAccountConstants.NULL;
        }
        stringBuilder.append("body:" + str);
        HMSLog.i("[HUAWEIIDSDK]HuaweiIdSignOutTaskApiCall", stringBuilder.toString());
    }
}
